package de.slothsoft.commons.swing.util;

import java.awt.GridBagConstraints;
import java.awt.Insets;

public class GridBagUtil {

	// are a bit down to anchor on the northwest and still appear to be on the
	// same height as text fields
	public static final Insets LABEL_INSETS = new Insets(8, 2, 2, 2);
	public static final Insets DEFAULT_INSETS = new Insets(2, 2, 2, 2);

	public static GridBagConstraints labelDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
				GridBagConstraints.HORIZONTAL, LABEL_INSETS, 0, 0);
	}

	public static GridBagConstraints textFieldDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
				GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints textAreaDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
				DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints buttonDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints buttonRightDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
				DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints toolBarButtonDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
				DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints fillDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
				DEFAULT_INSETS, 0, 0);
	}

	public static GridBagConstraints componentDefaults(int x, int y) {
		return new GridBagConstraints(x, y, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
				DEFAULT_INSETS, 0, 0);
	}

	private GridBagUtil() {
		// I'm on the run! (i.e. hidden)
	}

}
